#include "util/Observable.hpp"

Observable::Observable()
{
}

Observable::~Observable()
{
}
/**
 * Add an observer
 */
void Observable::AddObserver(Observer* observer)
{
    m_listOfObserver.push_back(observer);
}
/**
 * Remove Observer
 */
void Observable::DeletteObserver(Observer* observer)
{
    for (unsigned int i(0) ; i < this->m_listOfObserver.size() ; i++)
    {
        if(observer == m_listOfObserver[i])
        {
            m_listOfObserver.erase(m_listOfObserver.begin() + i);
            break;
        }
    }
}
/**
 * Notify an observer with an "int" Code and a pointer parameter
 */
void Observable::NotifyObserver(int code, void* parameter)
{
	// TODO lvl1 : dangerous bug with int code
    for (unsigned int i(0) ; i < this->m_listOfObserver.size() ; i++)
    {
        m_listOfObserver[i]->Notify(code, parameter);
    }
}
